<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>运营数据录入 </title>
    <link rel="stylesheet" href="/v3/css/basic.css" type="text/css"/>

    <script type="text/javascript" src="/v3/js/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="/v3/js/index.js"></script>
    <!--标准mui.css-->
    <link rel="stylesheet" href="/v3/mui/css/mui.min.css">
    <link href="/v3/mui/css/mui.picker.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="/v3/css/style.css" type="text/css"/>
</head>
<body>
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">运营数据录入</h1>
</header>
<div class="container mui-content">
    <div class="new-media-form">
        <div class="new-media-item">
                    <span class="label must" >
                        选择账号
                    </span>
            <div class="input-box select" id='showUserPicker'>
                <div id="account"></div>
            </div>
        </div>
        <div class="new-media-item">
                <span class="label must">
                    内容发布日期
                </span>
            <div class="input-box select" data-options='{"type":"date"}' id="chooseDate"></div>
        </div>
        <div class="new-media-item">
                    <span class="label must">
                        当前粉丝量
                    </span>
            <div class="input-box">
                <input type="text" name="currentNum" id="currentNum">
            </div>
        </div>
<!--        <div class="new-media-item">-->
<!--                    <span class="label must">-->
<!--                        新增粉丝-->
<!--                    </span>-->
<!--            <div class="input-box">-->
<!--                <input type="text" name="newNum" id="newNum">-->
<!--            </div>-->
<!--        </div>-->
        <div class="new-media-item">
                    <span class="label must">
                        观看量
                    </span>
            <div class="input-box">
                <input type="text" name="seeNum" id="seeNum">
            </div>
        </div>
        <div class="new-media-item">
                    <span class="label must">
                        点赞数
                    </span>
            <div class="input-box">
                <input type="text" name="likeNum" id="likeNum">
            </div>
        </div>
        <div class="new-media-item">
                    <span class="label must">
                        评论数
                    </span>
            <div class="input-box">
                <input type="text" name="replyNum" id="replyNum">
            </div>
        </div>
        <div class="new-media-item">
                    <span class="label">
                        分析总结
                    </span>
            <textarea name="summary" id="summary" cols="3" rows="5"></textarea>
        </div>
        <div class="new-media-item">
                    <span class="label">
                        改进措施
                    </span>
            <textarea name="measures" id="measures" cols="3" rows="5"></textarea>
        </div>
        <div class="opt-btn" id="mediaSava">
            提交
        </div>

        　　　
    </div>
</div>
</div>
</body>
<script src="/v3/mui/js/mui.min.js"></script>
<script src="/v3/mui/js/mui.picker.min.js"></script>


<script>
    var accountValue;
    var accountArr;


    (function($, doc) {

        // 选择账户
        $.init();
        $.ready(function() {
            /**
             * 获取对象属性的值
             * 主要用于过滤三级联动中，可能出现的最低级的数据不存在的情况，实际开发中需要注意这一点；
             * @param {Object} obj 对象
             * @param {String} param 属性名
             */
            var _getParam = function(obj, param) {
                return obj[param] || '';
            };
            var userPicker = new $.PopPicker();
            // console.log(JSON.stringify(accountArr));
            // userPicker.setData(accountArr);

            $.ajax({
                url: "/ajax/getMediaList",
                type: "get",
                dataType:"json",
                success:function (res) {
                    // console.log(JSON.stringify(res));
                    if(res.code == 0){
                        userPicker.setData(res.data);
                    }
                }
            })

            var showUserPickerButton = doc.getElementById('showUserPicker');
            var accoutBox = doc.getElementById('account');
            showUserPickerButton.addEventListener('tap', function(event) {
                userPicker.show(function(items) {
                    var text = items[0].text // 账户被选中的项的文字
                    accountValue = items[0].value // 账户被选中的项的值
                    accoutBox.innerText = text;
                });
            }, false);
        });
        // 选择日期
        var chooseDate = $('#chooseDate')[0];

        chooseDate.addEventListener('tap', function() {
            var _self = this;
            if(_self.picker) {
                _self.picker.show(function (rs) {
                    chooseDate.innerText = rs.text;
                    _self.picker.dispose();
                    _self.picker = null;
                });
            } else {
                var optionsJson = this.getAttribute('data-options') || '{}';
                var options = JSON.parse(optionsJson);
                var id = this.getAttribute('id');
                _self.picker = new $.DtPicker(options);
                _self.picker.show(function(rs) {
                    chooseDate.innerText = rs.text;
                    _self.picker.dispose();
                    _self.picker = null;
                });
            }

        }, false);
    })(mui, document);
    // 保存
    $('#mediaSava').click(function(){
        // accountValue 抖音账户
        var publishDate = $('#chooseDate').html() // 统计日期
        var currentNum = $('#currentNum').val() // 当前粉丝量
        // var newNum = $('#newNum').val() // 新增粉丝
        var seeNum = $('#seeNum').val() // 观看量
        var likeNum = $('#likeNum').val() // 点赞数
        var replyNum = $('#replyNum').val() // 评论数
        var summary = $('#summary').val() // 分析总结
        var improvement = $('#measures').val() // 改进措施

        // mui.alert('欢迎使用Hello MUI', 'Hello MUI', function() {
        //     info.innerText = '你刚关闭了警告框';
        // });
        var data = {
            'publishDate':publishDate,
            'accountId':accountValue,
            'userCount':currentNum,
            'viewCount':seeNum,
            'zanCount':likeNum,
            'commentCount':replyNum,
            'summary':summary,
            'improvement':improvement,
        }
        // console.log(JSON.stringify(data));

        $.ajax({
            url: "/ajax/media_data_input",
            type: "POST",
            dataType: "json",
            contentType: "application/json",
            data: JSON.stringify(data),
            success: function (res) {
                console.log(JSON.stringify(res));
                if(res.code == 0){
                    alert("添加成功！");
                    window.location.href = '/media/data_report_m';
                }else{
                    alert(res.msg);
                }
            }
        });

    })


</script>




</html>